import {  _decorator,Component,Node,UITransform} from 'cc'

const { ccclass,property } = _decorator



@ccclass('Cart')
export class Cart extends Component {


    speed:number = 0

    maxX:number = 0

    protected onLoad(): void {
        this.maxX = 1280 / 2 + 200
        this.node.on(Node.EventType.TOUCH_END,this.onTouchEnd,this)
    }


    protected update(dt: number): void {
        this.node.x += this.speed * dt
        if(this.node.x > this.maxX) {
            this.node.removeFromParent()
            this.destroy()
            return
        }
    }


    onTouchEnd() {
        this.speed = 150
    }
}